package org.verifictaion.make;

import java.util.Random;

/**
 * @author dty
 * @create 2024-07-18
 * 生成验证码
 */
public class RandomStringGenerator {
    public static String generateRandomString(int length) {
        String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        StringBuilder randomString = new StringBuilder();
        Random random = new Random();

        for (int i = 0; i < length; i++) {
            int randomIndex = random.nextInt(characters.length());
            randomString.append(characters.charAt(randomIndex));
        }

        return randomString.toString();
    }

//    public static void main(String[] args) {
//        String randomString = generateRandomString(6);
//        System.out.println(randomString);
//    }
}

